var title = "说明书";
var config = {
    url_page: _dir + "useDirector.html",
    url_add: _dir + "useDirector_add.html",
    title_page: title + "查询",
    title_list: title + "列表",
    title_add: "添加" + title,
    title_edit: "修改" + title,
    code_list: "/specification/query",
    //code_delete: "/specification/del",
    code_add: "/specification/input",
    code_edit: "/specification/update",
    //code_dataUpload: "/firmware/upload",
    code_imgUpload: "/files/upload",
    pagination_01: $("#page_01"),
};
$(document).ready(function () {
    if (_page == "useDirector_add") {
        var sendObj2 = {};
        var editorResult=myEditor('#editor',config['code_imgUpload']);
        //初始化
        var PageInit = function () {
            new setUpload($("#idCardParent"),{'uploadUrl':config['code_imgUpload'],"urlDom":$("#videoUrl")});
            var _fid = $.trim($.request.queryString["fid"]);
            var _fstaffNo = $.trim($.request.queryString["id"]);
            var _rtype = $.trim($.request.queryString["rtype"]);
            var _msgId = 0;
            this.get_fid = function () {
                return this._fid;
            };
            this.get_msgId = function () {
                return this._msgId;
            };
            this.set_fid = function (v) {
                this._fid = v;
            }
            this.set_msgId = function (v) {
                this._msgId = v;
            }
            _call(config['code_list'], sendObj2, function (res) {
                _trs = "";
                if (!res.body || res.body.length == 0) {
                    //添加
                    this.set_msgId(config['code_add']);
                    this.set_fid(0);
                    setTitle_02(config['title_add'],config['url_page']);

                }
                else {
                    $.each(res.body, function (i, v) {
                        $('#name').val(res.body[0].name);
                        $('#type').val(res.body[0].type);
                        $('#videoUrl').val(res.body[0].videoUrl);
                        editorResult.txt.html(res.body[0].content);
                    });

                }

            });
            this.setDefault = function (v) {
                if (_fid == "" && _fstaffNo == "" && _rtype == "") {
                    //添加
                    this.set_msgId(config['code_add']);
                    this.set_fid(0);
                    setTitle_02(config['title_add'],config['url_page']);
                }

            }

        };
        var _default = new PageInit();
        _default.setDefault();
        //提交事件
        $(".validate-form .submit").on("click", function () {
            var _this = $(this);
            sendObj2={};
            if ($(".validate-form").validate().form()) {
                sendObj2["name"] = $("#name").val();
                sendObj2["type"] = $("#type").val();
                sendObj2["videoUrl"] = $("#videoUrl").val();
                sendObj2["content"] = editorResult.txt.html();
                _call(_default.get_msgId(), sendObj2, function (res) {
                    confirm_add_ok(res, config['url_page'], function () {
                        window.location.href = window.location.href;
                    },'stay');
                });
            }
        });
    }
    // $(".select2").select2();
});